var e = require;
var t = module;
var o = exports;
(o.__esModule = !0), (o.default = void 0);
var n = (function () {
    function e() {
        (this.mAutoCloseTimeout = 0),
            (this.autoCloseInterval = null),
            (this.hideShareClose = 0),
            (this.rootNode = null);
    }
    var t = e.prototype;
    return (
        (t.closeToYou = function () {
            this.rootNode && this.rootNode.removeFromParent(),
                this.autoCloseInterval && clearInterval(this.autoCloseInterval);
        }),
        (t.createChaping = function (e, t, o) {
            var n =
                    e.imgUrlList && e.imgUrlList[0]
                        ? e.imgUrlList[0]
                        : e.iconUrlList && e.iconUrlList[0]
                        ? e.iconUrlList[0]
                        : null,
                i = e.source,
                a = e.title,
                r = cc.view.getVisibleSize(),
                s = (cc.v2(r.width / 2, r.height / 2), new cc.Node());
            (s.width = 10 * cc.winSize.width), (s.height = 10 * cc.winSize.height);
            var d = cc.director.getScene();
            (s.parent = d), (s.zIndex = cc.macro.MAX_ZINDEX), (s.group = lplatform.params.uiGroup);
            var c = new cc.Node();
            c.parent = s;
            var l = Math.min(cc.winSize.width, cc.winSize.height);
            if (
                ((c.width = 0.8 * l),
                lplatform.plog("createChaping:" + lplatform.channel),
                (c.height = (9 * c.width) / 16),
                "Oppo" != lplatform.channel || lplatform.labData.mainSwitch)
            ) {
                s.addComponent(cc.Button);
                var h = s.addComponent(cc.Graphics);
                (h.strokeColor = new cc.color(0, 0, 0, 180)),
                    (h.fillColor = new cc.color(0, 0, 0, 180)),
                    h.fillRect(-s.width / 2, -s.height / 2, s.width, s.height);
            }
            var u = new cc.Node();
            (u.parent = c), (u.x = 0), (u.y = -c.height / 2 - 90);
            var p = u.addComponent(cc.Sprite);
            lplatform.plog("adInfo.clickBtnTxt:" + e.clickBtnTxt),
                cc.loader.loadRes("ysguanggao/dakaibg", function (e, t) {
                    e ? console.log(e) : p && (p.spriteFrame = new cc.SpriteFrame(t));
                });
            var f = function f() {
                console.log("ad click"), o && o(), (lplatform.oppoNativeClick = null), s.destroy();
            };
            (lplatform.oppoNativeClick = f),
                u.on("touchend", f),
                (c.x = cc.winSize.width / 2),
                (c.y = cc.winSize.height / 2),
                c.on("touchend", f);
            var m = new cc.Texture2D();
            m.initWithData(new Uint8Array([0, 0, 0]), cc.Texture2D.PixelFormat.RGB888, 1, 1);
            var g = c.addComponent(cc.Sprite);
            (g.sizeMode = cc.Sprite.SizeMode.CUSTOM),
                (g.spriteFrame = new cc.SpriteFrame(m)),
                cc.assetManager && cc.assetManager.loadRemote
                    ? cc.assetManager.loadRemote(n, {ext: ".jpg"}, function (e, t) {
                          e || !t
                              ? (console.log("加载失败，ext .jpg, 尝试png"),
                                cc.assetManager.loadRemote(n, {ext: ".png"}, function (e, t) {
                                    e || !t
                                        ? console.log("加载失败，ext .png")
                                        : g && (g.spriteFrame = new cc.SpriteFrame(t));
                                }))
                              : g && (g.spriteFrame = new cc.SpriteFrame(t));
                      })
                    : cc.loader.load({url: n, type: "image"}, function (e, t) {
                          e ? console.log(e) : g && (g.spriteFrame = new cc.SpriteFrame(t));
                      });
            var w = new cc.Node();
            (w.parent = c),
                (w.width = 83),
                (w.height = 31),
                (w.x = -c.width / 2 + w.width / 2),
                (w.y = -c.height / 2 + w.height / 2);
            var v = w.addComponent(cc.Sprite);
            cc.loader.loadRes("ysguanggao/native_1", function (e, t) {
                e ? console.log(e) : (v.spriteFrame = new cc.SpriteFrame(t));
            });
            var b = new cc.Node();
            b.parent = c;
            var S = new cc.Node();
            if (
                ((S.parent = c),
                lplatform.plog("lplatform.cparam.closeBtnScale:" + lplatform.cparam.closeBtnScale + " "),
                lplatform.cparam.closeBtnScale >= 1
                    ? ((b.width = b.height = 58),
                      (S.width = S.height = 58),
                      (b.x = c.width / 2 + 50),
                      (b.y = c.height / 2 + 50),
                      (S.x = c.width / 2 + 50),
                      (S.y = c.height / 2 + 50))
                    : ((b.width = b.height = 58),
                      (S.width = S.height = 58),
                      (b.x = c.width / 2 - b.width / 2),
                      (b.y = c.height / 2 - b.height / 2),
                      (b.scale = lplatform.cparam.closeBtnScale),
                      (S.x = c.width / 2 - S.width / 2),
                      (S.y = c.height / 2 - S.height / 2)),
                (b.scale = lplatform.cparam.closeBtnScale),
                i && "undefined" != i)
            ) {
                var y = new cc.Node();
                (y.x = c.width / 2),
                    (y.y = -c.height / 2),
                    (y.anchorX = 1),
                    (y.anchorY = 0),
                    (y.parent = c),
                    (y.addComponent(cc.Label).string = i);
            }
            if (a && "undefined" != i) {
                var A = new cc.Node();
                (A.x = 0), (A.y = c.height / 2), (A.anchorY = 0), (A.parent = c), (A.addComponent(cc.Label).string = a);
            }
            b.on("touchend", function (e) {
                console.log("closeBtn click"), e.stopPropagation(), t && t(), s.removeFromParent();
            });
            var R = S.addComponent(cc.Sprite);
            return (
                (R.sizeMode = cc.Sprite.SizeMode.CUSTOM),
                cc.loader.loadRes("ysguanggao/native_3", function (e, t) {
                    e ? console.log(e) : R && (R.spriteFrame = new cc.SpriteFrame(t));
                }),
                s
            );
        }),
        (t.CreateShareK = function (e, t, o, n, i) {
            void 0 === n && (n = 0), void 0 === i && (i = !1);
            var a = lplatform.systemInfo,
                r = cc.view.getVisibleSize(),
                s = (cc.v2(r.width / 2, r.height / 2), new cc.Node());
            if (
                ((this.rootNode = s),
                (s.x = 0.5 * r.width),
                (s.y = 0.5 * r.height),
                (s.parent = cc.director.getScene()),
                (s.zIndex = cc.macro.MAX_ZINDEX),
                s.setContentSize(cc.winSize),
                (s.group = lplatform.params.uiGroup),
                o)
            ) {
                var d = new cc.Node();
                (d.zIndex = 1), (d.width = r.width), (d.height = r.height), (d.parent = s);
                var c = lGlobal.nodeShot(d, o, c),
                    l = new cc.SpriteFrame(c);
                l.setFlipY(!0),
                    (d.addComponent(cc.Sprite).spriteFrame = l),
                    cc.tween(d).to(0.5, {width: 691.5, height: 847.5, x: 0, y: 112}).start();
            }
            var h = new cc.Node();
            (h.parent = s),
                (h.opacity = 120),
                (h.scale = 1e3),
                cc.loader.loadRes("fenxiang/mask", function (e, t) {
                    h.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                }),
                s.on("touchstart", function () {}, this, !0),
                s.on("touchend", function () {}, this, !0);
            var u = new cc.Node();
            (u.parent = s),
                (u.x = 0),
                (u.y = 0),
                (u.scale = 1.5),
                (u.zIndex = 2),
                cc.loader.loadRes("fenxiang/share", function (e, t) {
                    u.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                });
            var p = new cc.Node();
            (p.parent = u),
                (p.x = 0),
                (p.scale = 0.9),
                (p.y = -295),
                cc.loader.loadRes("fenxiang/queding", function (e, t) {
                    p.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                }),
                p.on(cc.Node.EventType.TOUCH_END, function () {
                    e && e(), s.removeFromParent();
                });
            var f = new cc.Node();
            (f.parent = u),
                a.windowWidth > a.windowHeight ? ((f.x = 290), (f.y = 190)) : ((f.x = 190), (f.y = 310)),
                (f.scale = 1),
                cc.loader.loadRes("fenxiang/close", function (e, t) {
                    f.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                });
            var m = new cc.Node();
            (m.parent = u), (m.x = 0), (m.y = -240), (m.color = cc.color(3, 35, 79, 255));
            var g = m.addComponent(cc.Label);
            if (
                ((g.string = "秒自动关闭"),
                n
                    ? ((m.active = !0),
                      (this.mAutoCloseTimeout = n),
                      (this.autoCloseInterval = setInterval(
                          function () {
                              (this.mAutoCloseTimeout -= 0.016),
                                  (g.string = Math.ceil(this.mAutoCloseTimeout) + "秒自动关闭"),
                                  this.mAutoCloseTimeout <= 0 &&
                                      (this.autoCloseInterval && clearInterval(this.autoCloseInterval),
                                      console.log("auto close"),
                                      t && t(),
                                      s.removeFromParent());
                          }.bind(this),
                          16
                      )))
                    : m.active && (m.active = !1),
                (this.hideShareClose = lplatform.cparam.hideShareClose),
                Math.random() <= this.hideShareClose)
            )
                f.active = !1;
            else {
                f.scale = 0;
                var w = cc.delayTime(1),
                    v = cc.scaleTo(0.3, 1, 1).easing(cc.easeBackOut()),
                    b = cc.scaleTo(0.3, 10, 10).easing(cc.easeBackOut());
                f.runAction(cc.sequence(w, b, v));
            }
            if (
                (f.on(
                    cc.Node.EventType.TOUCH_END,
                    function () {
                        console.log("closeBtn click closeShare"),
                            t && t(),
                            s.removeFromParent(),
                            this.autoCloseInterval && clearInterval(this.autoCloseInterval);
                    }.bind(this)
                ),
                (u.opacity = 0),
                cc.tween(u).delay(0.3).to(0.4, {opacity: 255}).start(),
                i && "ios" !== a.platform)
            ) {
                var S = new cc.Node();
                (S.parent = s),
                    (S.x = -0.5 * r.width),
                    (S.y = 0.5 * r.height),
                    (S.anchorX = 0),
                    (S.anchorY = 1),
                    cc.loader.loadRes("fenxiang/adlist", function (e, t) {
                        S.addComponent(cc.Sprite).spriteFrame = new cc.SpriteFrame(t);
                        var o = cc.moveTo(6, cc.v2(-0.5 * r.width - 1e3 + r.width, 0.5 * r.height)),
                            n = cc.moveTo(6, cc.v2(-0.5 * r.width, 0.5 * r.height));
                        S.runAction(cc.repeatForever(cc.sequence(o, n)));
                    }),
                    S.on(cc.Node.EventType.TOUCH_END, function () {
                        lplatform.goToGameOrGameList(null);
                    });
            }
            return s;
        }),
        (t.getCanvas = function () {
            return cc.game.canvas;
        }),
        e
    );
})();
(o.default = n), (t.exports = o.default);
